home *** CD-ROM | disk | FTP | other *** search
/ L'Encyclopedie Des Jeux Video 8 / EJV8_CD2.ISO / ejv8-cd2 / somm.dxr / 00049_Auto Resize.ls < prev    next >
Encoding:
Text File  |  2003-10-24  |  2.1 KB  |  50 lines

  1. property DoitReadapterTailleImage, tailleorigin, X, Y
  2.  
  3. on beginSprite
  4.   X = the width of sprite the currentSpriteNum
  5.   Y = the height of sprite the currentSpriteNum
  6. end
  7.  
  8. on prepareFrame
  9.   resize1(the currentSpriteNum, the memberNum of sprite the currentSpriteNum, the castLibNum of sprite the currentSpriteNum)
  10.   sprite(the currentSpriteNum).visible = 1
  11. end
  12.  
  13. on resize1 NumDuSprite, NumDuMember, NumCastlib
  14.   member(NumDuMember, NumCastlib).centerRegPoint = 1
  15.   taille_d_origine(X, Y, NumDuMember, NumCastlib)
  16.   if (DoitReadapterTailleImage = 1) and ((getAt(tailleorigin, 1) > X) or (getAt(tailleorigin, 2) > Y)) then
  17.     compteclic = 0
  18.     set the floatPrecision to 2
  19.     if (float(X) / float(getAt(tailleorigin, 1))) < (float(Y) / float(getAt(tailleorigin, 2))) then
  20.       prctplusreduit = float(X) / float(getAt(tailleorigin, 1)) * 100
  21.       set the height of sprite NumDuSprite to float(getAt(tailleorigin, 2)) * float(prctplusreduit) / 100
  22.       set the width of sprite NumDuSprite to float(getAt(tailleorigin, 1)) * float(prctplusreduit) / 100
  23.     else
  24.       prctplusreduit = float(Y) / float(getAt(tailleorigin, 2)) * 100
  25.       set the width of sprite NumDuSprite to float(getAt(tailleorigin, 1)) * float(prctplusreduit) / 100
  26.       set the height of sprite NumDuSprite to float(getAt(tailleorigin, 2)) * float(prctplusreduit) / 100
  27.     end if
  28.   else
  29.     if (DoitReadapterTailleImage = 1) and ((the width of sprite NumDuSprite > X) or (the height of sprite NumDuSprite > Y)) then
  30.       compteclic = 0
  31.       set the width of sprite NumDuSprite to getAt(tailleorigin, 1)
  32.       set the height of sprite NumDuSprite to getAt(tailleorigin, 2)
  33.     else
  34.       set the width of sprite NumDuSprite to getAt(tailleorigin, 1)
  35.       set the height of sprite NumDuSprite to getAt(tailleorigin, 2)
  36.     end if
  37.   end if
  38.   updateStage()
  39. end
  40.  
  41. on taille_d_origine X, Y, NumDuMember, NumCastlib
  42.   global tailleorigin, DoitReadapterTailleImage
  43.   tailleorigin = list(member(NumDuMember, NumCastlib).width, member(NumDuMember, NumCastlib).height)
  44.   if (getAt(tailleorigin, 1) > X) or (getAt(tailleorigin, 2) > Y) then
  45.     DoitReadapterTailleImage = 1
  46.   else
  47.     DoitReadapterTailleImage = 0
  48.   end if
  49. end
  50.